    let data={
    promoterCode:'',
    alipayAccount:'',
    alipayName:'',
    createId:'',
    createTime:'',
    desensitizedAlipayAccount:'',
    desensitizedAlipayName:'',
    id:'',
    msgCode:'',
    phoneNum:'',
    phoneNumMd5:'',
}
    let timer
    function back(){
        window.location.href = 'withdraw.html'
    }
    function getData() {
        const storedData = localStorage.getItem('userData');
        if (storedData) {
            data = JSON.parse(storedData);
            if (data.alipayName) {
                $('#desensitizedAlipayName').val(data.alipayName);
            }

            if (data.alipayAccount) {
                $('#desensitizedAlipayAccount').val(data.alipayAccount);
            }
            if (data.phoneNum) {
                const phoneNum = data.phoneNum;
                // 将电话号码中间的四位替换为星号
                const formattedPhoneNum = phoneNum.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
                $('.num').text(formattedPhoneNum);
            }
        }
    }
    function bind(){
    // 获取三个输入框的值
        const realName = document.getElementById("desensitizedAlipayName").value.trim();
        const alipayAccount = document.getElementById("desensitizedAlipayAccount").value.trim();
        const smsCode = document.getElementById("duan").value.trim();
        if (!realName || !alipayAccount || !smsCode) {
            alert("请填入完整信息");
        } else {
            let params={
            msgCode:smsCode,
            alipayName: realName,
            alipayAccount: alipayAccount,
            id: data.id
            }
            var codeDiv = document.querySelector('.model');
            if (codeDiv.style.display !== 'none') {
                codeDiv.style.display = 'none';
            } else {
                codeDiv.style.display = 'block';
            }
            $.ajax({
                type: 'POST',
                url: httpUrl+'/api/v1/open/bindAliInfo',
                contentType: 'application/json',
                data: JSON.stringify(params),
                success: function(result) {
                    if(result.code=='10000'){
                        codeDiv.style.display = 'none';
                        setTimeout(()=>{
                            update()
                        },50)
                    }else{
                        codeDiv.style.display = 'none';
                        setTimeout(()=>{
                            alert(result.msg)
                        },50)
                    }

                },
                error: function(xhr, status, error) {
                    codeDiv.style.display = 'none';
                    setTimeout(()=>{
                        alert('网络波动，请稍后再试。');
                    },50)

                }
            });
        }
    }
    function getDuanMa() {
        if(timer){
            clearTimeout(timer)
        }
        // 手机号base64加密
        let phoneNumEnc = data.phoneNumMd5;
        $.ajax({
            type: 'GET',
            url: httpUrl+'/api/v1/open/bindAliMsg?phoneNumEnc='+phoneNumEnc,
            success: function(result) {
                if(result.code=='10000'){
                    $(".duanMa").hide();
                    $(".duanMaGet").show();
                    var countdown = 59;  // 设置倒计时为 59 秒
                    timer = setInterval(function() {
                        $(".duanMaGet").text("已发送(" + countdown + ")");
                        countdown--;
                        if (countdown < 0) {
                            clearInterval(timer);
                            $(".duanMa").show();
                            $(".duanMaGet").hide();
                        }
                    }, 1000);
                }else{
                    setTimeout(()=>{
                        alert(result.msg)
                    },50)
                }

                },
            error: function(xhr, status, error) {
                setTimeout(()=>{
                    alert('发送失败，请稍后再试。');
                },50)

            }
        });
    }
    function update(){
        let phoneNumEnc = data.phoneNumMd5;
        $.ajax({
            type: 'GET',
            url: httpUrl+'/api/v1/open/searchPromoterCode?phoneNumEnc='+phoneNumEnc,
            success: function(result) {
                if(result.code=='10000'){
                    localStorage.setItem('userData', JSON.stringify(result.data));
                    window.location.href = 'withdraw.html';
                }
            },
            error: function(xhr, status, error) {
            }
        });
    }
    getData()
